//
//  FZHomeStatus.swift
//  FZSina_Swift
//
//  Created by 李忠 on 7/24/16.
//  Copyright © 2016 FZLZ. All rights reserved.
//

import UIKit

class FZHomeStatus: NSObject {
//MARK:==========================属性==========================
    ///微博创建时间
    var created_at: String?
    ///微博ID
    var id: Int64 = 0
    ///	微博MID
    var mid: Int64 = 0
    //微博信息内容
    var text: String?
    ///	微博来源
    var source: String?
    
    /// 微博作者的用户信息字段
    var user: FZHomeUser?
    
    ///转发数
    var reposts_count: Int = 0
    ///评论数
    var comments_count: Int = 0
    ///表态数
    var attitudes_count: Int = 0
    
    //发表图片
    var pic_urls: [FZHomePictureInfo]?
    
    
    
    
    
    ///被转发的原微博信息字段，当该微博为转发微博时返回: 内容和首页Status一样，所以使用了FZHomeStatus类
    var retweeted_status: FZHomeStatus?
    
    init(dic: [String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dic)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            
            user = FZHomeUser(dic:(value as! [String: AnyObject]))
            
        }else if key == "retweeted_status"{
            
            retweeted_status = FZHomeStatus(dic: (value as! [String : AnyObject]))
            
        }else if key == "pic_urls"{
            
            guard let pic = value as? [[String: AnyObject]] else{
                return
            }
            var tempArray: [FZHomePictureInfo] = [FZHomePictureInfo]()
            
            for va in pic {
                
                let tempPic: FZHomePictureInfo = FZHomePictureInfo(dic: va)
                let large = tempPic.thumbnail_pic!.stringByReplacingOccurrencesOfString("thumbnail", withString: "large")
                let bmiddle = tempPic.thumbnail_pic!.stringByReplacingOccurrencesOfString("thumbnail", withString: "bmiddle")
                tempPic.original_pic = large
                tempPic.bmiddle_pic = bmiddle
                tempArray.append(tempPic)
                
            }
            pic_urls = tempArray
            
        }else{
             super.setValue(value, forKey: key)
        }
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    
    
    
    

}
